Previous Book Contents Book Index Next

Inside Macintosh: QuickTime /
Chapter 2 - Movie Toolbox / Using the Movie Toolbox


Using Movies in Your Event Loop

Your application needs to grant time to the Movie Toolbox to allow your movies to play. To do this, you call the MoviesTask function from your main event loop. The MoviesTask function (described on page 2-110) instructs the Movie Toolbox to service all your active movies. Call MoviesTask regularly so that your movie can play smoothly. You can use the UpdateMovie function to force your movie to be redrawn after it has been uncovered. It will not be redrawn until the next call to MoviesTask.

Your application should call UpdateMovie between the Window Manager's BeginUpdate and EndUpdate functions. (For details on BeginUpdate and EndUpdate, see Inside Macintosh: Macintosh ToolBox Essentials Essentials.) Do not call MoviesTask at this time. You will observe better display behavior if you call MoviesTask at the end of your update processing.

The code shown in Listing 2-13 demonstrates the use of the UpdateMovie function in a Window Manager update sequence. For the Movie Toolbox to know that it has to display (or update) a movie when MoviesTask is called, you must call UpdateMovie as shown. If you are using the movie controller component and call the MCIsPlayerEvent function, you do not need to call UpdateMovie in response to an update event. (See the chapter "Movie Controller Component" in Inside Macintosh: QuickTime Components, for details on MCIsPlayerEvent.)

Note
Contrary to normal update handling, where applications draw to the window in between calls to BeginUpdate and EndUpdate, you should not call MoviesTask.
The UpdateMovie function tells the Movie Toolbox that a portion of the movie has been invalidated. However, it is not redrawn until MoviesTask is called.

Listing 2-13 Handling movie update events

#include <Events.h>#include <ToolUtils.h>#include "Movies.h"
void DoUpdate (WindowPtr theWindow, Movie theMovie)
{
   BeginUpdate (theWindow);
   UpdateMovie (theMovie);
   EndUpdate (theWindow);
} /* DoUpdate */

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996